package helexis.game.tyrian;

import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Array;

public abstract class Assets {
	
	/*
	 * Front Gun 에 대한 프리뷰 이미지
	 */
	
	public static TextureRegionDrawable preview_frontGun_PULSE_CANNON;
	public static TextureRegionDrawable preview_frontGun_MISSILE_LAUNCHER;
	public static TextureRegionDrawable preview_frontGun_VULCAN_CANNON;
	public static TextureRegionDrawable preview_frontGun_PROTON_LAUNCHER;
	public static TextureRegionDrawable preview_frontGun_WAVE_CANNON;
	
	
	/*
	 * Shield 에 대한 프리뷰 이미지
	 */
	
	public static TextureRegionDrawable preview_shield_SIF;
	public static TextureRegionDrawable preview_shield_AIF;
	public static TextureRegionDrawable preview_shield_GLES;
	public static TextureRegionDrawable preview_shield_GHEF;
	public static TextureRegionDrawable preview_shield_MLXS;
	
	
	/*
	 * Ship Model 에 대한 프리뷰 이미지
	 */
	
	public static TextureRegionDrawable preview_shipModel_USP_TALON;
	public static TextureRegionDrawable preview_shipModel_GENCORE_PHOENIX;
	public static TextureRegionDrawable preview_shipModel_GENCORE_II;
	public static TextureRegionDrawable preview_shipModel_MICROSOL_STALKER;
	public static TextureRegionDrawable preview_shipModel_SUPER_CARROT;
	
	
	/**
	 * 프리뷰 이미지에 대한 Asset 들을 초기화 합니다.
	 * 
	 * @param atlas 프리뷰 이미지를 포함하는 텍스처 아틀라스
	 */
	public static void initPreviewImages(TextureAtlas atlas) {
		
		final String prefix = "start-game-screen/";
		
		preview_frontGun_PULSE_CANNON = createTextureRegionDrawable(atlas, preview_frontGun_PULSE_CANNON, prefix + "front-gun-pulse-cannon");
		preview_frontGun_MISSILE_LAUNCHER = createTextureRegionDrawable(atlas, preview_frontGun_MISSILE_LAUNCHER, prefix + "front-gun-missile-launcher");
		preview_frontGun_VULCAN_CANNON = createTextureRegionDrawable(atlas, preview_frontGun_VULCAN_CANNON, prefix + "front-gun-vulcan-cannon");
		preview_frontGun_PROTON_LAUNCHER = createTextureRegionDrawable(atlas, preview_frontGun_PROTON_LAUNCHER, prefix + "front-gun-proton-launcher");
		preview_frontGun_WAVE_CANNON = createTextureRegionDrawable(atlas, preview_frontGun_WAVE_CANNON, prefix + "front-gun-wave-cannon");
	
	
		preview_shield_SIF = createTextureRegionDrawable(atlas, preview_shield_SIF, prefix + "shield-sif");
		preview_shield_AIF = createTextureRegionDrawable(atlas, preview_shield_AIF, prefix + "shield-aif");
		preview_shield_GLES = createTextureRegionDrawable(atlas, preview_shield_GLES, prefix + "shield-gles");
		preview_shield_GHEF = createTextureRegionDrawable(atlas, preview_shield_GHEF, prefix + "shield-ghef");
		preview_shield_MLXS = createTextureRegionDrawable(atlas, preview_shield_MLXS, prefix + "shield-mlxs");
	
		
		preview_shipModel_USP_TALON = createTextureRegionDrawable(atlas, preview_shipModel_USP_TALON, prefix + "ship-model-usp-talon");
		preview_shipModel_GENCORE_PHOENIX = createTextureRegionDrawable(atlas, preview_shipModel_GENCORE_PHOENIX, prefix + "ship-model-gencore-phoenix");
		preview_shipModel_GENCORE_II = createTextureRegionDrawable(atlas, preview_shipModel_GENCORE_II, prefix + "ship-model-gencore-ii");
		preview_shipModel_MICROSOL_STALKER = createTextureRegionDrawable(atlas, preview_shipModel_MICROSOL_STALKER, prefix + "ship-model-microsol-stalker");
		preview_shipModel_SUPER_CARROT = createTextureRegionDrawable(atlas, preview_shipModel_SUPER_CARROT, prefix + "ship-model-super-carrot");
		
	}//end of initPreviewImages()
	
	
	/**
	 * 주어진 TextureRegionDrawable 을 null 체크하여
	 * null 일 경우에만 객체를 생성하여 리턴하는 유틸리티 메소드
	 * 
	 * @param atlas TextureAtlas
	 * @param drawable TextureRegionDrawable
	 * @param regionPath region 경로 (사실상 TextureAtlas 상의 ID)
	 * @return TextureRegionDrawable
	 */
	private static TextureRegionDrawable createTextureRegionDrawable(TextureAtlas atlas, TextureRegionDrawable drawable, String regionPath) {
		if (drawable == null) {
			return new TextureRegionDrawable(atlas.findRegion(regionPath));
		} else {
			return drawable;
		}//end if
	}//end of createTextureRegionDrawable()
	
	
	
	/*
	 * Ship Model 에 대한 이미지
	 */
	
	public static Array<AtlasRegion> shipModel_USP_TALON;
	public static Array<AtlasRegion> shipModel_GENCORE_PHOENIX;
	public static Array<AtlasRegion> shipModel_GENCORE_II;
	public static Array<AtlasRegion> shipModel_MICROSOL_STALKER;
	public static Array<AtlasRegion> shipModel_SUPER_CARROT;
	
	
	/**
	 * 프리뷰 이미지에 대한 Asset 들을 초기화 합니다.
	 * 
	 * @param atlas 프리뷰 이미지를 포함하는 텍스처 아틀라스
	 */
	public static void initShipModelImages(TextureAtlas atlas) {
		
		final String prefix = "level-screen/";
		
		shipModel_USP_TALON = createAtlasRegionArray(atlas, shipModel_USP_TALON, prefix + "ship-model-usp-talon");
		shipModel_GENCORE_PHOENIX = createAtlasRegionArray(atlas, shipModel_GENCORE_PHOENIX, prefix + "ship-model-gencore-phoenix");
		shipModel_GENCORE_II = createAtlasRegionArray(atlas, shipModel_GENCORE_II, prefix + "ship-model-gencore-ii");
		shipModel_MICROSOL_STALKER = createAtlasRegionArray(atlas, shipModel_MICROSOL_STALKER, prefix + "ship-model-microsol-stalker");
		shipModel_SUPER_CARROT = createAtlasRegionArray(atlas, shipModel_SUPER_CARROT, prefix + "ship-model-super-carrot");
	
	}//end of initShipModelImages()
	
	
	/**
	 * 주어진 Array&gt;AtlasRegion&lt; 를 null 체크하여
	 * null 일 경우에만 객체를 생성하여 리턴하는 유틸리티 메소드
	 * 
	 * @param atlas TextureAtlas
	 * @param regions Array<AtlasRegion>
	 * @param regionPath region 경로 (사실상 TextureAtlas 상의 ID)
	 * @return Array<AtlasRegion>
	 */
	private static Array<AtlasRegion> createAtlasRegionArray(TextureAtlas atlas, Array<AtlasRegion> regions, String regionPath) {
		if (regions == null) {
			return atlas.findRegions(regionPath);
		} else {
			return regions;
		}//end if
	}//end of createAtlasRegionArray()
	
	
}
//end of Assets.java